package com.qisu.config;

import org.beetl.sql.core.Interceptor;
import org.beetl.sql.ext.spring4.BeetlSqlDataSource;
import org.beetl.sql.ext.spring4.SqlManagerFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import com.ibeetl.starter.BeetlSqlSingleConfig;

/**
 * 
 * @author li
 *
 */
@Configuration
public class EnhancementBeetlsqlConfig extends BeetlSqlSingleConfig {
	@Autowired
	private EnhancementInterceptors enhancementInterceptors;

	@Override
	public SqlManagerFactoryBean getSqlManagerFactoryBean(BeetlSqlDataSource source, Environment env) throws Exception {

		SqlManagerFactoryBean sqlManagerFactoryBean = super.getSqlManagerFactoryBean(source, env);
		sqlManagerFactoryBean.setInterceptors(new Interceptor[] { enhancementInterceptors });
		return sqlManagerFactoryBean;
	}

}
